<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
%>

<html>
  <head>
    <title>上传图片</title>
    <link href="<%=path%>/css/index_css.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
     window.onload=function(){
     	 if(!parent||!parent.firendId){
         document.getElementById('firendId').value='${firendId}';
        }else{
     	document.getElementById('firendId').value=parent.firendId;
     	}
     	
     	if(!parent||!parent.fileType){
         document.getElementById('fileType').value='${fileType}';
        }else{
     	document.getElementById('fileType').value=parent.fileType;
     	}
     }
     
     function showImage()
     {
     	 var fileName=document.myform.file.value;
     	 var isOrNoImg=fileName.substring(fileName.lastIndexOf('.')+1,fileName.length).toUpperCase();
     	 if(fileName==''||fileName==null)
     	 {
     	 	alert("上传内容不能为空！");
     	 	return;
     	 }
     	 else if(isOrNoImg!='JPG'&&isOrNoImg!='BMP'&&isOrNoImg!='GIF'&&isOrNoImg!='PNG'&&isOrNoImg!='IOC')
     	 {
     	 	alert("插入的不是图片，请重新插入");
     	 	return;
     	 }
     	 document.myform.submit();
         document.getElementById('imgdiv').innerHTML="<img src='<%=path%>/images/loading.gif'>";
     }
    </script>
  </head>
  
  <body bgcolor="#DDDDDD">
    <form action="${applicationScope.currentEnclosureServer.outUrl }/enclosure/uploadCommonEnclosureFile.action" method="post" enctype="multipart/form-data" name="myform">
    <input type="hidden" name="commonEnclosureFile.firendId" value="" id="firendId">
	<input type="hidden" name="enclosureServer.serverId" value="${applicationScope.currentEnclosureServer.serverId}">
	<input type="hidden" name="commonEnclosureFile.fileType" id="fileType">
	<input type="hidden" name="isImg" value="1" id="isImg"><br>
    	<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
		  <tr>
		    <td align="left" valign="top" bgcolor="#DDDDDD" class="border_4">
		    <table width="100%" border="0" cellspacing="0" cellpadding="0">
		      <tr>
		        <td align="center" valign="top" class="tb_23"> 
		        <span id='imgdiv'>
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
		          <tr>
		            <td height="30" colspan="2" align="center"><input type="file" name="file" title="文件上传"></td>
		          </tr>
		          <tr>
		            <td height="30" colspan="2" align="center"><input type="button" onclick="showImage();" value="提交"></td>
		          </tr>
		          <tr>
		            <td colspan="2" align="center" valign="top" class="border_2 f_2"><img src="images/icon_82.gif" width="7" height="7" />支持同时上传多个附件，每个附件大小限制为200M.</td>
		          </tr>
		        </table>
		        </span></td>
		      </tr>
		    </table></td>
		  </tr>
		</table>
		
	</form>
  </body>
</html>
